#ifndef __SYSTIMER
#define __SYSTIMER

#include <Defs.h>

#define INT_AND_RES_MR0 0x3
#define INT_AND_RES_MR1 0x18
#define COUNTER_1Hz 12000000
#define COUNTER_800Hz 15000
#define COUNTER_4000Hz 3000
#define COUNTER_seconds(sec) COUNTER_1Hz*sec

#define SysTStartTimer0(); T0TCR = 1;		 	//Start timer 0. Hint.
#define SysTStartTimer1(); T1TCR = 1;		 	//Start timer 1. Hint.
#define SysTStopTimer0(); T0TCR = 0; 			//Stop time 0. Hint.
#define SysTStopTimer1(); T1TCR = 0; 			//Stop time 1. Hint.
#define SysTResetTimer1(); T1PC = 0; T1TC = 0; 	//Reset timer 1. Hint.

//Change timer 1 mode. Hint.
#define ENTER_TIMER_FOR_ADC SysTChangeVectorT1(); 
#define LEAVE_TIMER_FOR_ADC SysTChangeVectorT1(); 

extern void SysTInit(void (*externalHandlerForKeyboard)(void), void (*externalHandleForADC)(void));

extern uint SysTms(void);
extern uint SysTmsDelta(uint t);
extern void SysTmsDelay(uint ms);

extern void SysTChangeVectorT1(void);

#endif // __SYSTIMER
